import { http } from "@/utils/http";
import { baseAdminURLApi } from "../utils";
// 获取当前用户路由信息
interface Meta {
  title: string;
  icon: string;
  showLink: boolean;
  frameSrc: string;
  roles: Array<string>;
  auths: Array<string>;
}
interface RouteVO {
  path: string;
  name: string;
  component: string;
  meta: Meta;
  redirect: string;
  children: Array<RouteVO>;
}
export const getAsyncRoutes = () => {
  return http.request<RouteVO[]>("get", baseAdminURLApi("/menus/routers"));
};
// 获取菜单列表
interface SysMenu {
  id: number;
  name: string;
  title: string;
  path: string;
  component: string;
  icon: string;
  rank: number;
  type: number;
  btnPerm: string;
  showLink: number;
  frameSrc: string;
  parentId: number;
}
export const getMenuList = () => {
  return http.request<SysMenu[]>("get", baseAdminURLApi("/menus"));
};
// 新增菜单
export const addMenu = (data?: SysMenu) => {
  return http.request<boolean>("post", baseAdminURLApi("/menus"), {
    data
  });
};
// 修改菜单
export const updateMenu = (id: number, data?: object) => {
  return http.request<boolean>("put", baseAdminURLApi(`/menus/${id}`), {
    data
  });
};
// 删除菜单  1,2,3批量删除
export const delMenuById = (data?: Array<number>) => {
  return http.request<boolean>("delete", baseAdminURLApi("/menus"), {
    data
  });
};
